package com.atguigu.gmall.task.task;

import com.atguigu.gmall.common.constant.MqConst;
import com.atguigu.gmall.common.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author 李旭
 * @date 2021/12/7 11:47
 * @Description:
 *
 *
 */
@Component
public class TaskSeckill {

    @Autowired
    private RabbitService rabbitService;

    //定时任务   cron:表达式   后半夜  01:00:00
    //@Scheduled(cron = "0 0 1 * * ?")
    @Scheduled(cron = "0/5 * * * * ?") // 每5S执行一次
    public void task0(){
        System.out.println("每5S执行一次");
        //发消息  闹铃
        rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK,MqConst.ROUTING_TASK_1,"");

    }

}
